<?php

App::uses('SpotsController', 'Admin.Controller');

/**
 * TestSpotsController *
 */
class TestSpotsController extends SpotsController {
	
	public $autoRender = false;
	
	public function redirect($url, $status = null, $exit = true) {
		$this->redirectUrl = $url;
	}
	
	public function render($view = null, $layout = null) {
		$this->renderedAction = $view;
	}
	
}


/**
 * SpotsController Test Case
 *
 */
class SpotsControllerTestCase extends CakeTestCase {
	
	/**
	 * Fixtures
	 *
	 * @var array
	 */
	public $fixtures = array('app.spot', 'app.category', 'app.city', 'app.vote', 'app.item');
	
	/**
	 * setUp method
	 *
	 * @return void
	 */
	public function setUp() {
		parent::setUp();
		$this->Spots = new TestSpotsController();
		$this->Spots->constructClasses();
	}

	/**
	 * tearDown method
	 *
	 * @return void
	 */
	public function tearDown() {
		$this->Spots->Session->destroy();
		unset($this->Spots);
		parent::tearDown();
	}
	
	
	/**
	 * testIndex method
	 *
	 * @return void
	 */
	public function testIndex() {

		// Session data
		$this->Spots->Session->write("Auth.User", array (
			'id' => 1,
			'username' => 'admin'
		));
		
		// Request data
		$this->Posts->data = array (
			'q' => ''
		);
		
		$this->Spots->params = Router::parse('/admin/spots/index');
		$this->Spots->beforeFilter();
		$this->Spots->Component->startup($this->Spots);
		$this->Spots->index();
		
		$this->assertTrue(isset($this->Spots->viewVars['spots']));
	}
	
}